<?php $form=$this->beginWidget('booster.widgets.TbActiveForm',array(
	'id'=>Yii::app()->controller->id.'-form',
    'enableAjaxValidation' => false,
    'type' => 'horizontal',
    'htmlOptions' => array('enctype'=>'multipart/form-data'),
//       'clientOptions' => array(
//            'validateOnSubmit'=>true,
//            'validateOnChange'=>true,
//            'validateOnType'=>false,
//           ),
));

$satuan = CHtml::listData(Satuan::model()->findAll(array('select'=>'id,nama')),'id','nama');
$provinsi = CHtml::listData(Provinsi::model()->findAll(array('select'=>'id,nama')),'id','nama');
$kabupaten = CHtml::listData(Kabupaten::model()->findAll(array('select'=>'id,nama')),'id','nama');
if(Yii::app()->user->isOperatorMB())
    $jenisUsaha = array('Pengolahan MB'=>'Pengolahan Minyak Bumi');
elseif(Yii::app()->user->isOperatorGB())
    $jenisUsaha = array('Pengolahan GB'=>'Pengolahan Gas Bumi');
elseif(Yii::app()->user->isOperatorHO())
    $jenisUsaha = array('Pengolahan HO'=>'Pengolah Hasil Olahan');
else
    $jenisUsaha = array('Pengolahan MB'=>'Pengolahan Minyak Bumi','Pengolahan GB'=>'Pengolahan Gas Bumi','Pengolahan HO'=>'Pengolah Hasil Olahan');
?>
<?php echo $form->errorSummary($model); ?>
<div clas <p class="help-block">Field dengan tanda <span class="required">*</span> tidak boleh kosong.</p>
<div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title">DATA PERUSAHAAN</h3>
  </div>
  <div class="panel-body">
	<?php 
            echo $form->radioButtonListGroup($model, 'bentuk_badan_usaha', array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions' => array('class'=>'col-md-2','style'=>'display:inline'), 'separator' => ' ', 'widgetOptions' => array('data' => array('PT'=>'PT','CV'=>'CV','FA'=>'FA','PMA'=>'PMA'))));
            echo $form->textFieldGroup($model,'nama_perusahaan',array('hint'=>'Masukan Nama Perusahaan tanpa Badan Usaha.','wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control','maxlength'=>100))));
            echo $form->dropDownListGroup($model, 'jenis_usaha', array('wrapperHtmlOptions' => array('class' => 'col-md-8'), 'labelOptions' => array('class' => 'col-md-2'), 'widgetOptions' => array('data' => $jenisUsaha, 'htmlOptions' => array('empty' => Yii::t('app', 'Pilih Jenis Usaha..'),'class' => 'form-control')))); 
            echo $form->textFieldGroup($model,'alamat',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control','maxlength'=>200)))); 
            echo $form->textFieldGroup($model,'jenis_produk',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control','maxlength'=>50)))); 
            //echo $form->textFieldGroup($model,'pengurus',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control','maxlength'=>100)))); 
            //echo $form->textFieldGroup($model,'kapasitas',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control','maxlength'=>50)))); 
            //echo $form->textFieldGroup($model,'npwp',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control','maxlength'=>50))));
            //echo $form->textFieldGroup($model,'kota_id',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control')))); 
            //echo $form->textFieldGroup($model,'telepon',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control')))); 
            //echo $form->textFieldGroup($model,'fax',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control')))); 
            //echo $form->textFieldGroup($model,'mobile_phone',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control')))); 
            //echo $form->textFieldGroup($model,'kode_pos',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control')))); 
            //echo $form->textFieldGroup($model,'email',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control','maxlength'=>100)))); 
            //echo $form->textFieldGroup($model,'website',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control','maxlength'=>100)))); 
            //echo $form->radioButtonListGroup($model, 'kantor_cabang', array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions' => array('class'=>'col-md-2','style'=>'display:inline'), 'separator' => ' ', 'widgetOptions' => array('data' => array('Ya'=>'Ya','Tidak'=>'Tidak'))));
            //echo $form->fileFieldGroup($model, 'upload_dokumen', array('wrapperHtmlOptions' => array('class' => 'col-md-8'), 'labelOptions' => array('class' => 'col-md-2'), 'widgetOptions' => array('htmlOptions' => array('class' => 'form-control form-cascade-control', 'maxlength' => 255))));
        ?>
  </div>
</div>
<div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title">DATA PERIZINAN</h3>
  </div>
  <div class="panel-body">
                        <?php 
                                echo $form->textFieldGroup($izin,'nomor_sk',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control')))); 
                                  echo $form->datePickerGroup($izin,'tanggal_terbit',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('options'=>array('format'=>'yyyy-mm-dd'),'htmlOptions'=>array()), 'prepend'=>'<i class="glyphicon glyphicon-calendar"></i>')); 
                                 echo $form->datePickerGroup($izin,'tanggal_berakhir',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('options'=>array('format'=>'yyyy-mm-dd'),'htmlOptions'=>array()), 'prepend'=>'<i class="glyphicon glyphicon-calendar"></i>')); 
                                 echo $form->radioButtonListGroup($izin, 'jenis_izin', array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions' => array('class'=>'col-md-2','style'=>'display:inline'), 'separator' => ' ', 'widgetOptions' => array('data' => array('Sementara'=>'Sementara','Tetap'=>'Tetap'))));
                                 echo $form->textFieldGroup($izin,'kapasitas_pengolahan',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control','maxlength'=>20))));
                                 echo $form->dropDownListGroup($izin,'satuan_id', array('wrapperHtmlOptions'=>array('class'=>'col-md-5'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('data'=>$satuan, 'htmlOptions'=>array('empty' => Yii::t('app', 'Pilih Status Satuan..'),'class'=>'form-control'))));
                                 echo $form->select2Group($izin,'provinsi_id',array('groupOptions' => array('id' => 'TkProv'),'wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('data'=>$data['prov'],'htmlOptions'=>array('empty' => Yii::t('app', 'Pilih Provinsi..'),'class'=>'form-control form-cascade-control','maxlength'=>2)))); 
                                 echo $form->select2Group($izin, 'kabupaten_id', array('groupOptions' => array('id' => 'TkKab'), 'wrapperHtmlOptions' => array('class' => 'col-md-8'), 'labelOptions' => array('class' => 'col-md-2'), 'widgetOptions' => array('data' => null, 'asDropDownList' => false, 'options' => array('allowClear' => true, 'minimumInputLength' => 0, 'data' => 'js: function() { return {results: kabs}; }'), 'htmlOptions' => array('empty' => Yii::t('app', 'Pilih Kabupaten/Kota...'), 'placeholder' => Yii::t('app', 'Pilih Kabupaten/Kota...'), 'class' => 'form-control form-cascade-control', 'maxlength' => 4))));
                                 echo $form->textFieldGroup($izin,'alamat_kilang',array('hint'=>Yii::t('view','Isi tanpa nama Provinsi dan Kabupaten'),'wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control','maxlength'=>200)))); 
                                 echo $form->textFieldGroup($izin,'lokasi',array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('htmlOptions'=>array('class'=>'form-control form-cascade-control','maxlength'=>100)))); 
                                 echo $form->dropDownListGroup($izin,'status_izin', array('wrapperHtmlOptions'=>array('class'=>'col-md-8'),'labelOptions'=>array('class'=>'col-md-2'),'widgetOptions'=>array('data'=>array("Dalam Proses"=>"Dalam Proses","Masih Berlaku"=>"Masih Berlaku","Kadaluarsa"=>"Kadaluarsa",), 'htmlOptions'=>array('empty' => Yii::t('app', 'Pilih Status Izin..'),'class'=>'form-control')))); 
                                ?>
  </div>
</div>
<div class="form-group">
    <div class="col-sm-offset-3 col-sm-9 col-md-offset-2 col-md-8">
        <?php
        $this->widget('booster.widgets.TbButton', array(
            'buttonType' => 'submit',
            'context' => 'primary',
            'label' => Yii::t('app', 'Simpan'),
        ));
        ?>
        <?php
        $this->widget('booster.widgets.TbButton', array(
            'buttonType' => 'reset',
            'context' => 'danger',
            'label' => Yii::t('app', 'Batal'),
            'htmlOptions' => array('onclick' => 'history.go(-1);'),
        ));
        ?>
    </div>
</div>
<?php $this->endWidget(); ?>
<?php
$jse_code = (!$model->isNewrecord) ? "var kabs = " . CJSON::encode($data['oldk']) . ";" : "var kabs = [];";
Yii::app()->getClientScript()->registerScript("prg_data", $jse_code, CClientScript::POS_BEGIN);
Yii::app()->getClientScript()->registerScript("related_prov", "
var pv;
var ph = $('#Izin_kabupaten_id').attr('placeholder');
$('#Izin_provinsi_id').change(function() {
    var pr = this.value;
    if (pr != pv) {
        pv = this.value;
        $('#TkKab').find('.select2-allowclear').removeClass('select2-allowclear');
        $('#TkKab').find('.select2-chosen').empty().addClass('select2-default').html(ph);
    }
    if (pr != '') {
        var url = '" . CHtml::normalizeUrl(array('getKabupaten')) . "';
        $.getJSON(url, {id: pr}, function(data) { kabs = data; });
        $('#Izin_kabupaten_id').focus();
    }
});
$('#Izin_kabupaten_id').change(function() {
    if (this.value != '') { $('#TkKab').find('.select2-chosen').removeClass('select2-default'); }
});
", CClientScript::POS_READY
);
?>
<?php (Yii::app()->booster) ? Yii::app()->booster->registerYiiCss() : null; ?>
